﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             x:Class="MediaOwl.LastFm.Views.MusicTrackSingleView"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400">
    <UserControl.Resources>
        <DataTemplate x:Key="CompactItemTemplate">
            <Grid Width="90">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="50"
                           Height="50"
                           Margin="10,0" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}"
                           Width="50"
                           TextAlignment="Center" />
                <Image Source="{Binding PictureSmall}"
                       Width="50"
                       Height="50"
                       Stretch="UniformToFill"
                       Margin="10,0" />
                <TextBlock Margin="0,5"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="1"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center" />
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel Margin="5">
            <StackPanel Orientation="Horizontal"
                        d:LayoutOverrides="Height"
                        toolkit:DockPanel.Dock="Top"
                        Margin="0,0,0,15">
                <TextBlock TextWrapping="Wrap"
                           Text="Detail:"
                           Style="{StaticResource Heading2}"
                           d:LayoutOverrides="Width"
                           Margin="0,0,10,0" />
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           Style="{StaticResource Heading2}" />
            </StackPanel>
            <Border BorderBrush="{StaticResource ControlBorderBrush}"
                    BorderThickness="1"
                    toolkit:DockPanel.Dock="Bottom"
                    Margin="10,15,10,10"
                    CornerRadius="3"
                    Background="{StaticResource DarkInnerShadowDarkBrush}"
                    Padding="5">
                <Button x:Name="TryClose"
                        Content="Close"
                        HorizontalAlignment="Right" />
            </Border>
            <ScrollViewer Margin="0"
                          Style="{StaticResource CustomScrollViewerStyle}"
                          ScrollViewer.VerticalScrollBarVisibility="Auto"
                          d:LayoutOverrides="Height">
                <toolkit:DockPanel Margin="5">
                    <Grid toolkit:DockPanel.Dock="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock TextWrapping="Wrap"
                                   Text="Artist"
                                   Margin="5"
                                   VerticalAlignment="Center"
                                   Foreground="{StaticResource ControlForeground}" />
                        <TextBlock HorizontalAlignment="Left"
                                   TextWrapping="Wrap"
                                   Text="Album"
                                   VerticalAlignment="Center"
                                   Grid.Row="1"
                                   Margin="5"
                                   Foreground="{StaticResource ControlForeground}" />
                        <TextBlock TextWrapping="Wrap"
                                   Text="Listeners"
                                   Margin="5"
                                   VerticalAlignment="Center"
                                   Foreground="{StaticResource ControlForeground}"
                                   Grid.Row="2" />
                        <TextBlock HorizontalAlignment="Left"
                                   TextWrapping="Wrap"
                                   Text="Playcount"
                                   VerticalAlignment="Center"
                                   Grid.Row="3"
                                   Margin="5"
                                   Foreground="{StaticResource ControlForeground}" />
                        <TextBlock HorizontalAlignment="Left"
                                   TextWrapping="Wrap"
                                   Text="Duration"
                                   VerticalAlignment="Center"
                                   Grid.Row="4"
                                   Margin="5,5,0,5"
                                   Foreground="{StaticResource ControlForeground}" />
                        <TextBox Grid.Column="1"
                                 IsReadOnly="True"
                                 Margin="5,2,75,2"
                                 Text="{Binding CurrentTrack.ArtistName}"
                                 d:LayoutOverrides="Width" />
                        <Button x:Name="ShowArtist"
                                Content="Show"
                                Margin="0,0,5,0"
                                d:LayoutOverrides="Height"
                                Grid.Column="1"
                                HorizontalAlignment="Right"
                                Width="65"
                                VerticalAlignment="Center" />
                        <TextBox Text="{Binding CurrentTrack.AlbumName}"
                                 Grid.Row="1"
                                 Grid.Column="1"
                                 Margin="5,2,75,2"
                                 IsReadOnly="True"
                                 d:LayoutOverrides="Width" />
                        <Button x:Name="ShowAlbum"
                                Content="Show"
                                Margin="0,0,5,0"
                                Grid.Column="1"
                                HorizontalAlignment="Right"
                                Width="65"
                                VerticalAlignment="Center"
                                Grid.Row="1" />
                        <TextBox Grid.Column="1"
                                 d:LayoutOverrides="Width"
                                 IsReadOnly="True"
                                 Margin="5,2"
                                 Text="{Binding CurrentTrack.ListenersString}"
                                 Grid.Row="2" />
                        <TextBox Text="{Binding CurrentTrack.PlayCountString}"
                                 d:LayoutOverrides="Width"
                                 Grid.Row="3"
                                 Grid.Column="1"
                                 Margin="5,2"
                                 IsReadOnly="True" />
                        <TextBox Text="{Binding CurrentTrack.DurationString}"
                                 Grid.Row="4"
                                 Grid.Column="1"
                                 Margin="5,2"
                                 IsReadOnly="True"
                                 d:LayoutOverrides="Width" />
                        <StackPanel Grid.ColumnSpan="3"
                                    Margin="0,15"
                                    d:LayoutOverrides="Width, Height"
                                    Grid.Row="5">
                            <TextBox TextWrapping="Wrap"
                                     Text="{Binding CurrentTrack.Wiki.Content}"
                                     IsReadOnly="True"
                                     d:LayoutOverrides="Width, GridBox"
                                     FontWeight="Normal"
                                     VerticalScrollBarVisibility="Disabled" />
                            <TextBlock Text="{Binding CurrentTrack.Wiki.Published}"
                                       TextAlignment="Right"
                                       Foreground="{StaticResource ControlForeground}"
                                       d:LayoutOverrides="Width" />
                        </StackPanel>
                        <Rectangle Margin="5,2"
                                   Grid.RowSpan="6"
                                   Stroke="{StaticResource ColorAccentBrush}"
                                   RadiusX="3"
                                   RadiusY="3"
                                   Grid.Column="2"
                                   Width="130"
                                   Height="130"
                                   Fill="{StaticResource TreeViewItemSelectionBorder}"
                                   VerticalAlignment="Top" />
                        <TextBlock HorizontalAlignment="Center"
                                   TextWrapping="Wrap"
                                   Text="No Image"
                                   VerticalAlignment="Top"
                                   Foreground="{StaticResource ControlForeground}"
                                   Grid.Column="3"
                                   Grid.RowSpan="6"
                                   Margin="0,60,0,0" />
                        <Rectangle Margin="5,2"
                                   Grid.RowSpan="6"
                                   RadiusX="3"
                                   RadiusY="3"
                                   Grid.Column="2"
                                   Width="130"
                                   Height="130"
                                   Cursor="Hand"
                                   Visibility="{Binding CurrentTrack.PictureVisibility, FallbackValue=Collapsed}"
                                   VerticalAlignment="Top">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseLeftButtonUp">
                                    <cal:ActionMessage MethodName="OpenPicture" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <Rectangle.Fill>
                                <ImageBrush Stretch="UniformToFill"
                                            ImageSource="{Binding CurrentTrack.Picture}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Grid>
                    <TextBlock TextWrapping="Wrap"
                               Text="Similar Tracks"
                               toolkit:DockPanel.Dock="Top"
                               Style="{StaticResource Heading5}"
                               Margin="5,15,5,5" />
                    <ListBox x:Name="SimilarTracks"
                             ItemTemplate="{StaticResource CompactItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             toolkit:DockPanel.Dock="Top">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenSimilar">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=SimilarTracks}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                    <TextBlock TextWrapping="Wrap"
                               Text="Most Popular Tags"
                               toolkit:DockPanel.Dock="Top"
                               Style="{StaticResource Heading5}"
                               Margin="5,15,5,5" />
                    <ListBox x:Name="Tags"
                             ItemTemplate="{StaticResource TagItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.VerticalScrollBarVisibility="Disabled"
                             toolkit:DockPanel.Dock="Top">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenTag">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=Tags}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </toolkit:DockPanel>
            </ScrollViewer>
        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
